//
//  RegisterViewController.m
//  gee
//
//  Created by gakaki on 11-5-16.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "RegisterViewController.h"


@implementation RegisterViewController


@synthesize txt_username;
@synthesize txt_password;
@synthesize txt_email;

@synthesize btn_resert;
@synthesize btn_register;
@synthesize bar_return;
@synthesize btn_background;


- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}


-(IBAction)bar_return_click:(id)sender{
    [self dismissModalViewControllerAnimated:TRUE];

}
-(IBAction)handleRegisterClick:(id)sender{
        
    [self dismis_the_keyboard];
    
    NSLog(@"%@",txt_username.text);
    NSLog(@"%@",txt_password.text);
    NSLog(@"%@",txt_email.text);
    
    
    if ([self register_user]) {
    
    
    //注册成功 跳转到个人首页
        [self dismissModalViewControllerAnimated:TRUE];
        
             }else{
        //注册失败 提示错误
        UIAlertView *alert = [[UIAlertView alloc] 
                              initWithTitle:@"注册失败" 
                              message:@"注册出现错误" 
                              delegate:self 
                              cancelButtonTitle:@"取消" 
                              otherButtonTitles:nil];
        [alert show];
        [alert release];
        
    }
}

-(BOOL)register_user{
    return FALSE;
}

-(IBAction)resetText:(id)sender{
    
    [self dismis_the_keyboard];
    
    txt_username.text = @"";
    txt_password.text = @"";
}

-(void)dismis_the_keyboard{
    [txt_password resignFirstResponder];
    [txt_username resignFirstResponder];
    [txt_email resignFirstResponder];
}
-(IBAction)backgroundTap:(id)sender{

    [self dismis_the_keyboard];

}



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    
    [txt_username   release];         
    [txt_password   release];      
    [txt_email      release];  
    [btn_register   release];
    [btn_resert     release];     
    
    [btn_background release];    
    
    
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
}

- (void)viewDidUnload
{
    txt_username          =nil;
    txt_password          =nil;
    txt_email             =nil;
    btn_register          =nil;
    btn_resert            =nil;
    
    btn_background        =nil;
    [super viewDidUnload];
    
    
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end